package com.admin.util;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Page<T> implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Page(){}
	public Page(String currentPage,String pageSize){
		if(null != currentPage && currentPage != ""){
			this.currentPage = Integer.parseInt(currentPage);
		}
		if(null != pageSize && pageSize != ""){
			this.pageSize = Integer.parseInt(pageSize);
		}
	}
	
	/**
	 * 查询结果集
	 */
	private List<T> result = new ArrayList<T>();
	
	/**
	 * 总条数
	 */
	private long totalCount;
	
	/**
	 * 每页显示条数
	 */
	private int pageSize = 20;
	
	/**
	 * 当前页
	 */
	private int currentPage = 1;
	
	/**
	 * 查询开始行下标
	 */
	private int startIndex;
	
	/**
	 * 排序字段
	 */
	private String orderField;
	
	/**
	 * 排序方式
	 */
	private String orderDirection;

	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}

	public long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(long totalCount) {
		this.totalCount = totalCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	
	public int getStartIndex() {
		return (this.currentPage - 1) * pageSize;
	}
	
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public String getOrderField() {
		return orderField;
	}
	public void setOrderField(String orderField) {
		this.orderField = orderField;
	}
	public String getOrderDirection() {
		return orderDirection;
	}
	public void setOrderDirection(String orderDirection) {
		this.orderDirection = orderDirection;
	}
}
